cd "...\data set folder" /* define the directory where the replication package is */
log using "log_weeks_2008.smcl", replace


/* Audience Costs, Domestic Economy, and Coercive Diplomacy */
/* replication code - Weeks (2008) */


/* open Weeks (2008) data */
/* Data was prepared by running Weeks (2008) replication code, WeeksIO.do, from line 9 to line 153 */
use "data_weeks_2008.dta", clear


/* create aggregated category of audience cost sensitive autocracies */
gen auto_ac=military1+hybrid1+dynastic1+nondynastic1+single1+other1


/* analysis */
set more off
logit recip demdum1 auto_ac majmaj minmaj majmin capshare1 contig ally s_wt_glo  s_ld_1 s_ld_2 revter revgov revpol revoth if year>1945 & year<2000, robust cluster(cwkeynum) 
outreg2 using "result_weeks.doc", stats(coef pval) symbol(*) alpha(0.1)

logit recip i.demdum1##c.growthrate i.auto_ac##c.growthrate majmaj minmaj majmin capshare1 contig ally s_wt_glo  s_ld_1 s_ld_2 revter revgov revpol revoth if year>1945 & year<2000, robust cluster(cwkeynum) 
outreg2 using "result_weeks.doc", stats(coef pval) symbol(*) alpha(0.1)
margins, dydx(demdum1) at(growthrate=(-.65(.2)1)) level(90)
marginsplot, title("") ytitle("Marginal effects") xtitle("Annual GDP growth") yline(0, lpattern(dash))
graph save figurea2_1.gph, replace
margins, dydx(auto_ac) at(growthrate=(-.65(.2)1)) level(90)
marginsplot, title("") ytitle("Marginal effects") xtitle("Annual GDP growth") yline(0, lpattern(dash))
graph save figurea3_1.gph, replace

logit recip i.demdum1##c.growthrate_bi auto_ac##c.growthrate_bi majmaj minmaj majmin capshare1 contig ally s_wt_glo  s_ld_1 s_ld_2 revter revgov revpol revoth if year>1945 & year<2000, robust cluster(cwkeynum) 
outreg2 using "result_weeks.doc", stats(coef pval) symbol(*) alpha(0.1)
margins, dydx(demdum1) at(growthrate_bi=(-.4(.1).65)) level(90)
marginsplot, title("") ytitle("Marginal effects") xtitle("Biannual GDP growth") yline(0, lpattern(dash))
graph save figurea2_2.gph, replace
margins, dydx(auto_ac) at(growthrate_bi=(-.4(.1).65)) level(90)
marginsplot, title("") ytitle("Marginal effects") xtitle("Biannual GDP growth") yline(0, lpattern(dash))
graph save figurea3_2.gph, replace

logit recip i.demdum1##c.growthrate_pc auto_ac##c.growthrate_pc majmaj minmaj majmin capshare1 contig ally s_wt_glo  s_ld_1 s_ld_2 revter revgov revpol revoth if year>1945 & year<2000, robust cluster(cwkeynum) 
outreg2 using "result_weeks.doc", stats(coef pval) symbol(*) alpha(0.1)
margins, dydx(demdum1) at(growthrate_pc=(-.65(.2).95)) level(90)
marginsplot, title("") ytitle("Marginal effects") xtitle("Annual per-capita GDP growth") yline(0, lpattern(dash))
graph save figurea2_3.gph, replace
margins, dydx(auto_ac) at(growthrate_pc=(-.65(.2).95)) level(90)
marginsplot, title("") ytitle("Marginal effects") xtitle("Annual per-capita GDP growth") yline(0, lpattern(dash))
graph save figurea3_3.gph, replace

logit recip i.demdum1##c.growthrate_pc_bi auto_ac##c.growthrate_pc_bi majmaj minmaj majmin capshare1 contig ally s_wt_glo  s_ld_1 s_ld_2 revter revgov revpol revoth if year>1945 & year<2000, robust cluster(cwkeynum) 
outreg2 using "result_weeks.doc", stats(coef pval) symbol(*) alpha(0.1)
margins, dydx(demdum1) at(growthrate_pc_bi=(-.30(.1).55)) level(90)
marginsplot, title("") ytitle("Marginal effects") xtitle("Biannual per-capita GDP growth") yline(0, lpattern(dash))
graph save figurea2_4.gph, replace
margins, dydx(auto_ac) at(growthrate_pc_bi=(-.30(.1).55)) level(90)
marginsplot, title("") ytitle("Marginal effects") xtitle("Biannual per-capita GDP growth") yline(0, lpattern(dash))
graph save figurea3_4.gph, replace

graph combine figurea2_1.gph figurea2_2.gph figurea2_3.gph figurea2_4.gph, title("")
graph save figurea2.gph, replace

graph combine figurea3_1.gph figurea3_2.gph figurea3_3.gph figurea3_4.gph, title("")
graph save figurea3.gph, replace



log close

clear
